#! /usr/bin/python3
# coding=utf-8
# @time: 2025/10/23 19:30
# @Author:鹤川
import time

from selenium.webdriver.common.by import By
from pages.basePage import BasePage
from pages.loginPage import LoginPage
from pages.myInfoPage import MyInfoPage


#首页页面
class IndexPage(BasePage):
    #属性登录、我的账号
    eloginOrUname = (By.XPATH,"//*[@id='ECS_MEMBERZONE']/a[1]")
    indaccot = (By.XPATH, "//*[@class='header_r']/a[1]")
    #方法进入登录、进入我的账号页面
    def go_to_myInfoPage(self):
        #判断是否登录，如果是未登录，则进行登录操作
        if self.getELeTxt(self.findEle(self.eloginOrUname))=='登录':
            lp=self.go_to_loginPage()   #进入登录页面
            lp.login()                  #进行登录操作
        time.sleep(3)
        ccot = self.findEle(self.indaccot)  #点击我的账号（已登录）
        self.eleClick(ccot)
        return MyInfoPage(self.driver)
    def go_to_loginPage(self):
        #点击登录按钮
        self.eleClick(self.findEle(self.eloginOrUname))
        #得到登录页面对象
        lp=LoginPage(self.driver)
        return lp


if __name__ == '__main__':
    # ip=IndexPage()
    # lp=ip.go_to_myInfoPage()
    # lp.login()    #同时首页实现登录
    myMSG = IndexPage().go_to_myInfoPage().go_to_myMSGPage()
    # myOrder = IndexPage().go_to_myInfoPage().go_To_OrderPage()
    # myMSG.addMsg("测试主题","哒哒哒",r"E:\Work\codings\python\2506project\WebAutoECShop\datas\aaa.txt")

    myMSG.addMsg("测试主题","哒哒哒","aaa.txt")






